﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Reflection;

namespace Flame.Dlr
{
    public static class AssemblyHelper
    {
        public static IEnumerable<AssemblyWrapper> CurrentAppDomainAssemblies
        {
            get
            {
                return from x in AppDomain.CurrentDomain.GetAssemblies() select new AssemblyWrapper(x);
            }
        }

        public static IEnumerable<AssemblyWrapper> CurrentFlameAssemblies
        {
            get
            {
                return from x in CurrentAppDomainAssemblies where x.FullName.Contains("Flame") select x;
            }
        }

        public static void Apply(IEnumerable<AssemblyWrapper> assemblyInfos, IExecutable exec)
        {
            foreach (var a in assemblyInfos)
            {
                try
                {
                    exec.AddAssembly(a);
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine(e);
                }
            }
        }
    }
}
